package cn.demoncat.util.lang.constant.card;

/**
 * 营业执照类型
 *
 * @author 延晓磊
 * @since 2020年10月26日
 */
public enum BusinessLicenseType {

    LLC("1", "有限责任公司"),
    LLCS("2", "股份有限责任公司"),
    IBE("3", "个人独资企业"),
    PB("4", "合伙企业"),
    IB("5", "个体工商户");

    private final String type;
    private final String name;

    BusinessLicenseType(String type, String name) {
        this.type = type;
        this.name = name;
    }

    /**
     * 获取枚举
     *
     * @param type
     * @return
     */
    public static BusinessLicenseType get(String type){
        for (BusinessLicenseType value : values()) {
            if (value.type.equals(type)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 获取枚举
     *
     * @param name
     * @return
     */
    public static BusinessLicenseType getByName(String name){
        if (name.contains("个体")) {
            return IB;
        }else if (name.contains("合伙")) {
            return PB;
        }else if (name.contains("独资")) {
            return IBE;
        }else if (name.contains("股份")) {
            return LLCS;
        }else{
            return LLC;
        }
    }

    public String getType() {
        return type;
    }

    public String getName() {
        return name;
    }
}
